package com.bbz.spring.Conditional;


import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class WindowsConditional implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        //获取Bean
        ConfigurableListableBeanFactory configurableListableBeanFactory=context.getBeanFactory();
        //获取ClassLoader
        ClassLoader classLoader=context.getClassLoader();
        //获取环境变量
        Environment environment=context.getEnvironment();
        if(environment.getProperty("os.name").contains("Windows")){
            return true;
        }
        return false;
    }
}
